package main

import (
	"errors"
	"fmt"
	"math/rand"
	"gitee.com/carollia/data-sdk-go/model"
	"strconv"
	"time"
)
import "gitee.com/carollia/data-sdk-go/service"

func GetService() (s *service.Service, err error) {
	config := &model.Config{
		GameType: "RPG",
		GameId:   3,
		Secret:   "faedc06871847fd5b2b67a2628a73372",
		//Url:      "http://172.12.15.88:8010/data_api/events_report",
		Url:         "http://172.13.1.230:8016/data_api/events_report",
		Timeout:     3,
		CronSpec:    "0/5 * * * * ?",
		MaxSize:     100,
		LogLevel:    "info",
		MaxQueue:    500,
		MaxConsumer: 5,
		Compression: "None",
		Timezone:    "Asia/Shanghai",
	}
	s, err = service.NewService(config)
	return
}
func main() {

	// 构建一个全局任务调度对象
	ss, err := GetService()
	if err != nil {
		err = errors.New(fmt.Sprintf("响应错误:%d", err))
		return
	}
	i := 0
	for {
		if i < 5 {
			rand.Seed(time.Now().Unix())
			number := strconv.Itoa(rand.Intn(100000))
			accountId := strconv.Itoa(i)
			accountId = "1000" + accountId
			err := ss.Action("$$statis_$online", "statis", -1, map[string]interface{}{
				"value": number,
				"os":    "ios",
				"media": "今日头条",
			})
			if err != nil {
				fmt.Println("err:", err)
			}
		}
		i++
		//time.Sleep(time.Second)
	}

}
